﻿using System;
using System.Windows.Forms;

namespace ATEGo
{
    /// <summary>
    /// messgebox
    /// </summary>
    public class MsgShow
    {
        public static DialogResult Hint(string message, string caption = "提示")
        {
            return MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
        }
        public static DialogResult Warning(string message, string caption = "警告")
        {
            return MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
        }
        public static DialogResult Error(string message, string caption = "错误")
        {
            return MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
        }
        public static DialogResult Ask_YesNo(string message, string caption = "询问")
        {
            return MessageBox.Show(message, "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
        }
        public static DialogResult OK(string message, string caption = "成功")
        {
            return MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
        }
        public static DialogResult Hint(IExecutorForm thisForm, string message, string caption = "提示")
        {
            Func<DialogResult> t = () =>
            {
                return Hint(message, caption);
            };
            return (DialogResult)thisForm.Invoke(t);
        }
        public static DialogResult Warning(IExecutorForm thisForm, string message, string caption = "警告")
        {
            Func<DialogResult> t = () =>
            {
                return Warning(message, caption);
            };
            return (DialogResult)thisForm.Invoke(t);
        }
        public static DialogResult Error(IExecutorForm thisForm, string message, string caption = "错误")
        {
            Func<DialogResult> t = () =>
            {
                return Error(message, caption);
            };
            return (DialogResult)thisForm.Invoke(t);
        }
        public static DialogResult Ask_YesNo(IExecutorForm thisForm, string message, string caption = "询问")
        {
            Func<DialogResult> t = () =>
            {
                return Ask_YesNo(message, caption);
            };
            return (DialogResult)thisForm.Invoke(t);
        }
        public static DialogResult OK(IExecutorForm thisForm, string message, string caption = "成功")
        {
            Func<DialogResult> t = () =>
            {
                return OK(message, caption);
            };
            return (DialogResult)thisForm.Invoke(t);
        }
    }
}
